package src.java.easy;

import java.util.HashMap;

public class Solution205 {
    public boolean isIsomorphic(String s, String t) {
        HashMap<Character, Character> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            Character c = map.get(s.charAt(i));
            if (c == null) {
                boolean b = map.containsValue(t.charAt(i));
                if (b) {
                    return false;
                }
                map.put(s.charAt(i), t.charAt(i));
            }else if (c!= t.charAt(i)) {
                return false;
            }
        }
        return true;
    }
}
